#pragma once
#include "WeaponDlg.h"
#include "Items.h"
#include "afxwin.h"

// CItemsDlg dialog

#define ITEMS_LOAD   "\\items.ini"
#define ITEMS_SAVE   "\\items.ini"

class CItemsDlg : public CDialog
{
	DECLARE_DYNAMIC(CItemsDlg)

public:
	CItemsDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~CItemsDlg();

// Dialog Data
	enum { IDD = IDD_ITEMS };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
private:
	WEAPONTYPE *Weapon;
	ARMOURTYPE *Armour;
	MAGTYPE *Magazine;
	EXPLOSIVETYPE *Explosive;
	CaliberStruct *gCalibers;	
	AMMOTYPE *gAmmoTypes;
	WEAPONCLASS *gWeaponClass;
	CaliberBinds *ftbBinds;
  bool m_bSaved;
public:
  bool IsSaved() const { return m_bSaved; }
	afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
	//Class pointers
	CWeaponDlg *pWeapDlg;
	CWeapTTX   *pWeapTTX;
	CAttachDlg *pAttachDlg;
  COXToolTipCtrl m_tooltip;
	void SetClassPointers(ClassPointers *p);
	//--------------------------------------
	void FillWeaponStructures(WSPointers *pWSPointers);
	INVTYPE Item[MAXITEMS];
	INVTYPE *pItem;
	void OnOK();
	void OnCancel();
	void Load( CProgressBarDialog *pProgressDialog );
	void GetItemsIniSettings( CProgressBarDialog *pProgressDialog );

	int GetCursorIdByName(LPCTSTR tsClass);
	int GetItemClassIdByName(LPCTSTR tsClass);
	char* GetItemClassNameByID(DWORD IC);
	int GetItemClassCBIdByID(DWORD ID);
	int GetItemClassIdByCBID(DWORD ID);
	char* GetCursorNameByID(DWORD Cursor);
	int GetCursorCBIdByID(DWORD ID);
	int GetCursorIdByCBID(DWORD ID);

	void MakeLongFileName(CString * str);

	void ChangeSel();
	void FillIL();
	void FillIC();
	void FillCur();

	static const unsigned int MAXITEMS				= 2048;
	static const unsigned int SIZE_SHORT_ITEM_NAME  = 160;
	static const unsigned int SIZE_ITEM_NAME		= 160;
	static const unsigned int SIZE_ITEM_INFO		= 480;

	//item description
	UINT16 ItemNames[MAXITEMS][80];
	UINT16 ShortItemNames[MAXITEMS][80];
	void LoadAllItemNames( void );
	BOOLEAN LoadShortNameItemInfo(UINT16 ubIndex, UINT16 *pNameString );
	BOOLEAN LoadItemInfo(UINT16 ubIndex, UINT16 *pNameString, UINT16 *pInfoString );

	char *ITEMSTRINGFILENAME;
	TCHAR FilePath[255];

	//C++ implementation
	CListBox m_lbItems;
	CComboBox m_cbItemClass;
	CComboBox m_cbCursor;
	CButton m_chbDamage;
	CButton m_chbRepairable;
	CButton m_chbWaterDam;
	CButton m_chbMetal;
	CButton m_chbSinks;
	CButton m_chbShowStatus;
	CButton m_chbHiddenAddon;
	CButton m_chbTwoHanded;
	CButton m_chbNotBuy;
	CButton m_chbAttachment;
	CButton m_chbBigGunList;
	CButton m_chbNotEdit;
	CButton m_chbDefUndrop;
	CButton m_chbUnAero;
	CButton m_chbElectronic;
	CButton m_chbVeryBig;

  CSTIviewer m_stivSmallPict;
  CSTIviewer m_stivMidPict;
  CSTIviewer m_stivBigPict;

	afx_msg void OnLbnSelchangeListItems();
	afx_msg void OnCbnSelchangeComboItemClass();
	afx_msg void OnEnChangeEditIndexInClass();
	afx_msg void OnCbnSelchangeComboItemCursor();
	afx_msg void OnEnChangeEditGraphSetNum();
	afx_msg void OnEnChangeEditPictNum();
	afx_msg void OnEnChangeEditWeight();
	afx_msg void OnEnChangeEditBigSlotNum();
	afx_msg void OnEnChangeEditPrice();
	afx_msg void OnEnChangeEditUsability();
	afx_msg void OnEnChangeEditReliability();
	afx_msg void OnEnChangeEditRepairErase();
	afx_msg void OnBnClickedCheckDamageable();
	afx_msg void OnBnClickedCheckRepairable();
	afx_msg void OnBnClickedCheckWaterDamages();
	afx_msg void OnBnClickedCheckMetal();
	afx_msg void OnBnClickedCheckSinks();
	afx_msg void OnBnClickedCheckShowStatus();
	afx_msg void OnBnClickedCheckHiddenAddon();
	afx_msg void OnBnClickedCheckTwoHanded();
	afx_msg void OnBnClickedCheckBuyable();
	afx_msg void OnBnClickedCheckAttach();
	afx_msg void OnBnClickedCheckBigGunList();
	afx_msg void OnBnClickedCheckNotEditor();
	afx_msg void OnBnClickedCheckDefaultUndroppable();
	afx_msg void OnBnClickedCheckNoThrow();
	afx_msg void OnBnClickedCheckElectronic();
	afx_msg void OnBnClickedCheckIsVeryBig();
  void OnPaint( HDC &hdc, CRect &rc );
	void Save();
public:
  afx_msg void OnPaint();
  BOOL PreTranslateMessage(MSG* pMsg) 
  {
    if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST)
      m_tooltip.RelayEvent(pMsg);

    return CDialog::PreTranslateMessage(pMsg);
  }
};
